//
//  MyViewController.m
//  day1
//
//  Created by 于跃隆 on 2020/4/3.
//  Copyright © 2020 于跃隆. All rights reserved.
//

#import "MyViewController.h"
#import "MydeTableViewCell.h"
//三方轮播
#import "SDCycleScrollView.h"

//登录页面
#import "LoginViewController.h"

//cell子页面
#import "YaoQMViewController.h"
#import "SwViewController.h"
#import "GFkfViewController.h"
#import "BanSViewController.h"
#import "YaoQzViewController.h"
#import "MeiRQViewController.h"
#import "KanSpViewController.h"
#import "KanXwViewController.h"
#import "PaiHBViewController.h"
#import "JieSRwViewController.h"
#import "LiJtgViewController.h"
#import "LiJQDViewController.h"
#import "SettingViewController.h"
#import "TiXViewController.h"
#import "peopleMesViewController.h"
#import "YuEViewController.h"
#import "AtNumBViewController.h"

//model
#import "MyCollectionModel.h"
#import "imageArrayModel.h"



@interface MyViewController ()<UITableViewDelegate , UITableViewDataSource,SDCycleScrollViewDelegate,UINavigationControllerDelegate,UIScrollViewDelegate>{
    UIImageView *TouiamgeBtn;
    UIButton *Namebtn;
}

 @property (nonatomic,getter=isPushing) BOOL pushing;   // 记录 push 的标记，用于：从源头上解决，页面的多 push 问题

@property (nonatomic , strong) UITableView *table;

@property (nonatomic , strong) NSArray *sectionOZArr;
@property (nonatomic , strong) NSArray *sectionOFArr;
@property (nonatomic , strong) NSArray *sectionOImageArr;
@property (nonatomic , strong) NSArray *sectionOBtnArr;

@property (nonatomic , strong) NSArray *sectionTZArr;
@property (nonatomic , strong) NSArray *sectionTFArr;
@property (nonatomic , strong) NSArray *sectionTImageArr;

//表格头视图
@property (nonatomic , strong) UITableViewHeaderFooterView *GRheaderView;
//头分区view
@property (nonatomic , strong) UIView *sectionView;
//头视图的白色view
@property (nonatomic , strong) UIView *Whiteview;

//广告轮播图片arr
@property(nonatomic,strong) NSMutableArray * SCrlImageArray;


//轮播数组
@property(nonatomic,strong) NSMutableArray * urlArray;
@property(nonatomic,strong) NSMutableArray * ImageArray;
@property(nonatomic,copy) NSArray * imgArray;

//轮播model
@property(nonatomic,strong) imageArrayModel * ArrayModel;


@end

@implementation MyViewController

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = YES;
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
    [self.navigationController.navigationBar removeAllSubviews];
    self.ImageArray =  [NSMutableArray array];
    self.urlArray =  [NSMutableArray array];
    [self getSCrlImageArray];
    [self.table reloadData];
}
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    self.navigationController.navigationBar.hidden = YES;
    

}
-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
    
    self.navigationController.navigationBar.hidden = YES;
}


//-(void)viewWillDisappear:(BOOL)animated{
//    [super viewWillDisappear:animated];
//
//    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
//    [UIApplication sharedApplication].statusBarHidden = NO;
//
//    self.navigationController.navigationBar.hidden = YES;
//
//
//    self.sectionOImageArr = @[@"yaoQ",@"qianD",@"kan",@"wen",@"bang",@"wu"];
//    self.sectionOZArr = @[@"邀请赚钱",@"每日签到",@"看视频赚钱",@"看新闻赚钱",@"排行榜冲刺",@"未解锁任务"];
//    self.sectionOFArr = @[@"邀请好友赚钱 邀请越多 奖励越大",@"签到领红包 最高可获得10000金币",@"今日剩余20次",@"海量资讯任意看快速了解最新动态",@"海量咨询任意看快速了解最新动态",@"连续七天签到 即可解锁更多任务"];
//    self.sectionOBtnArr = @[@"+8888元",@"+20元",@"+88元",@"奖励无上限",@"周周赢大奖",@"冲刺转好礼"];
//
//    self.sectionTImageArr = @[@"ma",@"shang",@"guan",@"sheng"];
//    self.sectionTZArr = @[@"邀请码   ",@"商务合作",@"官方客服",@"版本升级"];
//    self.sectionTFArr = @[@"  我的邀请码",@"QQ:7777777",@"    联系客服",@"       V3.0"];
//
//    self.SCrlImageArray = [[NSMutableArray alloc] init];
//    self.urlArray = [[NSMutableArray alloc] init];
//    self.ImageArray = [[NSMutableArray alloc] init];
//    [self getSCrlImageArray];
//
//
//    [self.table reloadData];
//
//
//
//}
//给轮播栏内容附初始值A
-(void)getSCrlImageArray{
    self.SCrlImageArray = [NSMutableArray arrayWithArray:@[@"立即开启",@"工商银行",@"立即开启",@"工商银行"]];
    self.ImageArray = [NSMutableArray array];
    self.urlArray= [NSMutableArray array];
    
    [[NetWorkManager sharedManager] getData:@"api/carousel/getCarousel" parameters:@{} success:^(NSURLSessionDataTask *task, id responseObject) {
        if ([responseObject[@"code"] isEqualToNumber:@200]) {
            self.ArrayModel = [imageArrayModel yy_modelWithJSON:responseObject];
            for (imageArrayModelResult *list in self.ArrayModel.result) {
                [self.ImageArray addObject:list.imageUrl];
                if (![UtilTools isBlankString:list.jumpUrl]) {
                    [self.urlArray addObject:list.jumpUrl];
                }else{
                    [self.urlArray addObject:@""];
                }
            }
        }
        __weak typeof(self) weakSelf = self;
        dispatch_async(dispatch_get_main_queue(), ^{
            [weakSelf.table reloadData];
//            [weakSelf.table reloadSectionIndexTitles];
            
//            [weakSelf.table reloadRowsAtIndexPaths:[weakSelf.table indexPathsForVisibleRows] withRowAnimation:UITableViewRowAnimationRight];
            //or UITableViewRowAnimationRight达到刷新效果。
        });
        NSLog(@"图片图片图片图片图片--%@",self.ImageArray);
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];
    
}
// 重写父类方法
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    //~下面代码是解决页面的多次 push 使用~

    if (self.pushing ==  YES) {

         NSLog(@"被拦截");

        return;

    }else{

         NSLog(@"被push");

        self.pushing = YES;

    }
    
}
//导航控制器的代理方法的实现（为了解决页面 的多次 push 的问题）
-(void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
    self.pushing = NO;
    
}

- (void)viewDidLoad {
    
    
    

    self.navigationController.navigationBar.hidden = YES;
    
    self.view.backgroundColor = [UIColor colorWithRed:245/255.0 green:246/255.0 blue:251/255.0 alpha:1.0];
    
    
    UserModel *user = [UserModel sharedInstance:UserKey0];
    if ([UtilTools isBlankString:user.token]) {
        self.sectionOImageArr = @[@"yaoQ",@"qianD",@"kan",@"wen",@"bang",@"wu"];
        self.sectionOZArr = @[@"邀请赚钱",@"每日签到",@"看视频赚钱",@"看新闻赚钱",@"排行榜冲刺",@"未解锁任务"];
        self.sectionOFArr = @[@"邀请好友赚钱 邀请越多 奖励越大",@"签到领红包 最高可获得10000金币",@"今日剩余20次",@"海量资讯任意看快速了解最新动态",@"海量咨询任意看快速了解最新动态",@"连续七天签到 即可解锁更多任务"];
        self.sectionOBtnArr = @[@"+8888元",@"+20元",@"+88元",@"奖励无上限",@"周周赢大奖",@"冲刺转好礼"];
        
        self.sectionTImageArr = @[@"ma",@"shang",@"guan",@"sheng"];
        self.sectionTZArr = @[@"邀请码   ",@"商务合作",@"官方客服",@"版本升级"];
        self.sectionTFArr = @[@"  我的邀请码",@"QQ:7777777",@"    联系客服",@"         V3.0"];
    }else{
        self.sectionOImageArr = @[@"yaoQ",@"qianD",@"kan",@"wen",@"bang",@"wu",@""];
        self.sectionOZArr = @[@"邀请赚钱",@"每日签到",@"看视频赚钱",@"看新闻赚钱",@"排行榜冲刺",@"未解锁任务",@""];
        self.sectionOFArr = @[@"邀请好友赚钱 邀请越多 奖励越大",@"签到领红包 最高可获得10000金币",@"今日剩余20次",@"海量资讯任意看快速了解最新动态",@"海量咨询任意看快速了解最新动态",@"连续七天签到 即可解锁更多任务",@""];
        self.sectionOBtnArr = @[@"+8888元",@"+20元",@"+88元",@"奖励无上限",@"周周赢大奖",@"冲刺转好礼",@""];
        
        self.sectionTImageArr = @[@"ma",@"shang",@"guan",@"sheng",@""];
        self.sectionTZArr = @[@"邀请码   ",@"商务合作",@"官方客服",@"版本升级",@""];
        self.sectionTFArr = @[@"  我的邀请码",@"QQ:7777777",@"    联系客服",@"         V3.0",@""];
    }
    
    
    self.ImageArray = [NSMutableArray array];
    self.urlArray = [NSMutableArray array];
    self.SCrlImageArray = [[NSMutableArray alloc] init];
    
    [self.table reloadData];
    [self.view addSubview:self.table];
    
}
-(UITableView *)table{
    if (!_table) {
        _table = [[UITableView alloc] initWithFrame:CGRectMake(0, KSCHEIGHT(-40), self.view.frame.size.width, self.view.frame.size.height+KSCHEIGHT(40)) style:UITableViewStyleGrouped];
        _table.delegate = self;
        _table.dataSource = self;
        _table.separatorColor = [UIColor clearColor];
        _table.sectionFooterHeight = KSCHEIGHT(10);
        _table.sectionHeaderHeight = KSCHEIGHT(0);
        
    }
    return _table;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.01;
}
//头像点击事件
-(void)touBtnClick:(UIButton *)btn{
    UserModel *user = [UserModel sharedInstance:UserKey0];
    if ([UtilTools isBlankString:user.token]) {
               [NotLoginView gotoLoginViewController];
    }else{
    LoginViewController *logion = [[LoginViewController alloc] init];
    [self.navigationController pushViewController:logion animated:NO];
    }
}
//设置点击事件
-(void)SzBtnClick:(UIButton *)btn{
    UserModel *user = [UserModel sharedInstance:UserKey0];
    if ([UtilTools isBlankString:user.token]) {
               [NotLoginView gotoLoginViewController];
    }else{
    SettingViewController *settV = [[SettingViewController alloc] init];
    [self.navigationController pushViewController:settV animated:NO];
    }
}
//推广点击事件
-(void)ZtuiBClcik:(UIButton *)btn{
    UserModel *user = [UserModel sharedInstance:UserKey0];
    if ([UtilTools isBlankString:user.token]) {
               [NotLoginView gotoLoginViewController];
    }else{
    LiJtgViewController *lijTV = [[LiJtgViewController alloc] init];
    [self.navigationController pushViewController:lijTV animated:NO];
    }
}
//name点击事件
-(void)NameBClick:(UIButton *)btn{
    UserModel *user = [UserModel sharedInstance:UserKey0];
    if ([UtilTools isBlankString:user.token]) {
               [NotLoginView gotoLoginViewController];
    }else{
    peopleMesViewController *peopleV = [[peopleMesViewController alloc] init];
    [self.navigationController pushViewController:peopleV animated:NO];
    }
}
//签到点击事件
-(void)QDbClick:(UIButton *)btn{
    UserModel *user = [UserModel sharedInstance:UserKey0];
    if ([UtilTools isBlankString:user.token]) {
               [NotLoginView gotoLoginViewController];
    }else{
    LiJQDViewController *lijQV = [[LiJQDViewController alloc] init];
    [self.navigationController pushViewController:lijQV animated:NO];
    }
}
//金币点击事件
-(void)GoldBclick:(UIButton *)btn{
    UserModel *user = [UserModel sharedInstance:UserKey0];
    if ([UtilTools isBlankString:user.token]) {
               [NotLoginView gotoLoginViewController];
    }else{
    AtNumBViewController *atnumV = [[AtNumBViewController alloc] init];
    [self.navigationController pushViewController:atnumV animated:NO];
    }
}
//当前金币点击事件
-(void)AtGoldClick:(UIButton *)btn{
    UserModel *user = [UserModel sharedInstance:UserKey0];
    if ([UtilTools isBlankString:user.token]) {
               [NotLoginView gotoLoginViewController];
    }else{
    AtNumBViewController *atnumV = [[AtNumBViewController alloc] init];
    [self.navigationController pushViewController:atnumV animated:NO];
    }
}
//右侧箭头点击事件
-(void)LeftJObtnClick:(UIButton *)btn{
    UserModel *user = [UserModel sharedInstance:UserKey0];
    if ([UtilTools isBlankString:user.token]) {
               [NotLoginView gotoLoginViewController];
    }else{
    AtNumBViewController *atnumV = [[AtNumBViewController alloc] init];
    [self.navigationController pushViewController:atnumV animated:NO];
    }
}
//余额点击事件
-(void)SumbClick:(UIButton *)btn{
    UserModel *user = [UserModel sharedInstance:UserKey0];
    if ([UtilTools isBlankString:user.token]) {
               [NotLoginView gotoLoginViewController];
    }else{
    TiXViewController *tixV = [[TiXViewController alloc] init];
    [self.navigationController pushViewController:tixV animated:NO];
    }
}
//当前余额点击事件
-(void)AtSumClick:(UIButton *)btn{
    UserModel *user = [UserModel sharedInstance:UserKey0];
    if ([UtilTools isBlankString:user.token]) {
               [NotLoginView gotoLoginViewController];
    }else{
    TiXViewController *tixV = [[TiXViewController alloc] init];
    [self.navigationController pushViewController:tixV animated:NO];
    }
}
//余额旁箭头点击事件
-(void)LeftJTClick:(UIButton *)btn{
    UserModel *user = [UserModel sharedInstance:UserKey0];
    if ([UtilTools isBlankString:user.token]) {
               [NotLoginView gotoLoginViewController];
    }else{
    TiXViewController *tixV = [[TiXViewController alloc] init];
    [self.navigationController pushViewController:tixV animated:NO];
    }
}
//提现点击事件
-(void)TxbtnClick:(UIButton *)btn{
    UserModel *user = [UserModel sharedInstance:UserKey0];
    if ([UtilTools isBlankString:user.token]) {
               [NotLoginView gotoLoginViewController];
    }else{
    TiXViewController *tixV = [[TiXViewController alloc] init];
    [self.navigationController pushViewController:tixV animated:NO];
    }
}

//-(void)setSCrollViewF{
//    //广告栏
//    SDCycleScrollView *cycleScrollView3 = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(kSCRATIO(10), KSCHEIGHT(335), kSCRATIO(355), kSCRATIO(180)) delegate:self placeholderImage:[UIImage imageNamed:@"placeholder"]];
//    ViewRadius(cycleScrollView3, 5);
//    cycleScrollView3.currentPageDotImage = [UIImage imageNamed:@"pageControlCurrentDot"];
//    cycleScrollView3.pageDotImage = [UIImage imageNamed:@"pageControlDot"];
//    cycleScrollView3.imageURLStringsGroup = self.ImageArray;
//    [cycleScrollView3 adjustWhenControllerViewWillAppera];
//    [_GRheaderView addSubview:cycleScrollView3];
//
//    [cycleScrollView3 mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerX.mas_equalTo(_Whiteview);
//        make.bottom.mas_equalTo(_Whiteview.bottom).mas_equalTo(kSCRATIO(-15));
//        make.width.mas_equalTo(kSCRATIO(355));
//        make.height.mas_equalTo(KSCHEIGHT(140));
//    }];
//
//
//
//}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 4;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 2) {
        UserModel *user = [UserModel sharedInstance:UserKey0];
        if ([UtilTools isBlankString:user.token]) {
            return 6;
        }else{
            return 7;
        }
        
    }else if(section == 3){
        return 4;
    }else{
        return 1;
    }
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *CellIdentifier = @"Cell";
    MydeTableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    if (!cell) {
        cell = [[MydeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    
    if (indexPath.section == 0) {
//        [cell removeAllSubviews];
        UITableViewCell *cell = [[UITableViewCell alloc] init];
        if (!cell) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        }
        cell.userInteractionEnabled = YES;
        tableView.rowHeight = KSCHEIGHT(300);
        _sectionView = [[UIView alloc] init];
        _sectionView.userInteractionEnabled = YES;
        _Whiteview.userInteractionEnabled = YES;
        [cell addSubview:self.sectionView];
        [self sectionControlFrame];
        
        return cell;
        
    }else if (indexPath.section == 1) {
        
        tableView.rowHeight = KSCHEIGHT(140);
        [cell removeAllSubviews];
        //广告栏
        SDCycleScrollView *cycleScrollView3 = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(kSCRATIO(10), KSCHEIGHT(335), kSCRATIO(355), kSCRATIO(180)) delegate:self placeholderImage:[UIImage imageNamed:@"placeholder"]];
        ViewRadius(cycleScrollView3, KSCHEIGHT(5));
        cycleScrollView3.currentPageDotImage = [UIImage imageNamed:@"pageControlCurrentDot"];
        cycleScrollView3.pageDotImage = [UIImage imageNamed:@"pageControlDot"];
        cycleScrollView3.imageURLStringsGroup = self.ImageArray;
        [cycleScrollView3 adjustWhenControllerViewWillAppera];
        [cell addSubview:cycleScrollView3];
        
        [cycleScrollView3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(KSCHEIGHT(0));
            make.bottom.mas_equalTo(KSCHEIGHT(0));
            make.left.mas_equalTo(kSCRATIO(0));
            make.right.mas_equalTo(kSCRATIO(0));
            
        }];
        
    }else if (indexPath.section == 2) {
//        [cell removeAllSubviews];
        [cell setSeparatorInset:UIEdgeInsetsMake(KSCHEIGHT(0), kSCRATIO(30), KSCHEIGHT(0), kSCRATIO(0))];
        tableView.rowHeight = KSCHEIGHT(60);
//        cell.TextLabel.text = @"";
        cell.yaoImageV.image = [UIImage imageNamed:self.sectionOImageArr[indexPath.row]];
        cell.yaoImageVT.image = [UIImage imageNamed:@"HOT"];
        cell.TextLabel.text = self.sectionOZArr[indexPath.row];
        cell.DetailLabel.text = self.sectionOFArr[indexPath.row];
        [cell.yaobtn setTitle:self.sectionOBtnArr[indexPath.row] forState:UIControlStateNormal];
        cell.yaobtn.tag = indexPath.row;
        [cell.yaobtn addTarget:self action:@selector(yaoBtnclick:) forControlEvents:UIControlEventTouchUpInside];
        
        //底横线
        UIView *lineView = [[UIView alloc] init];
        lineView.backgroundColor = [UIColor colorWithRed:229/255.0 green:229/255.0 blue:229/255.0 alpha:1.0];
        [cell addSubview:lineView];
        
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(KSCHEIGHT(0));
            make.left.mas_equalTo(kSCRATIO(60));
            make.right.mas_equalTo(kSCRATIO(-10));
            make.height.mas_equalTo(KSCHEIGHT(0.01));
        }];
        
        
        UserModel *user = [UserModel sharedInstance:UserKey0];
        if (indexPath.row == 2) {
            
        }else if (indexPath.row == 5) {
            lineView.hidden = YES;
            
            
        }else if (indexPath.row == 6){
            [cell removeAllSubviews];
            
            lineView.hidden = YES;
            cell.backgroundColor =  [UIColor colorWithRed:245/255.0 green:246/255.0 blue:251/255.0 alpha:1.0];
            
            
            if ([UtilTools isBlankString:user.token]) {
                
                
                
            }else{
                
            }
            
            tableView.rowHeight = KSCHEIGHT(105);
            
            
            //白色背景view1手势方法
            UITapGestureRecognizer *chaWhitOneGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(touchWhieOneVevent:)];
            //白色背景view2手势方法
            UITapGestureRecognizer *chaWhitTwoGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(touchWhieTwoVevent:)];
            //白色背景view3手势方法
            UITapGestureRecognizer *chaWhitThreeGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(touchWhieThreeVevent:)];
            
            
            //白色背景veiw1
            UIView *whiteOneBV = [[UIView alloc] init];
            [whiteOneBV addGestureRecognizer:chaWhitOneGes];
            whiteOneBV.frame = CGRectMake(17.5,887,340,105);
            whiteOneBV.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
//            whiteOneBV.layer.cornerRadius = 6;
            [cell addSubview:whiteOneBV];
            
            [whiteOneBV mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerX.mas_equalTo(cell);
                make.width.mas_equalTo(kSCRATIO(340));
                make.height.mas_equalTo(KSCHEIGHT(35));
                make.top.mas_equalTo(KSCHEIGHT(0));
            }];
            //标题imageV
            UIImageView *whiteOneimgV = [[UIImageView alloc] init];
            whiteOneimgV.clipsToBounds = NO;
            whiteOneimgV.userInteractionEnabled = NO;
            whiteOneimgV.image = [UIImage imageNamed:@"cha1"];
            [whiteOneBV addSubview:whiteOneimgV];
            [whiteOneimgV mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.mas_equalTo(whiteOneBV);
                make.left.mas_equalTo(kSCRATIO(10));
                make.width.height.mas_equalTo(kSCRATIO(29));
            }];
            //标题label
            UILabel *whiteOnelabel = [[UILabel alloc] init];
            whiteOnelabel.numberOfLines = 0;
            whiteOnelabel.userInteractionEnabled = NO;
            whiteOnelabel.text = @"第一等级任务已解锁";
            whiteOnelabel.textColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
            whiteOnelabel.font = kFONT(KSCHEIGHT(12));
            [whiteOneBV addSubview:whiteOnelabel];
            [whiteOnelabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.mas_equalTo(whiteOneBV);
                make.left.mas_equalTo(whiteOneimgV.mas_right).mas_equalTo(kSCRATIO(10));
            }];
            //查看按钮
            UIButton *whiteOnebtn = [[UIButton alloc] init];
            whiteOnebtn.userInteractionEnabled = NO;
            [whiteOnebtn setFont:kFONT(KSCHEIGHT(11))];
            [whiteOnebtn setBackgroundImage:[UIImage imageNamed:@"立即查看"] forState:UIControlStateNormal];
            [whiteOneBV addSubview:whiteOnebtn];
            [whiteOnebtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.mas_equalTo(whiteOneBV);
                make.right.mas_equalTo(kSCRATIO(-20));
                
            }];
            
            //白色背景veiw2
            UIView *whiteTwoBV = [[UIView alloc] init];
            [whiteTwoBV addGestureRecognizer:chaWhitTwoGes];
            whiteTwoBV.frame = CGRectMake(17.5,887,340,105);
            whiteTwoBV.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
//            whiteOneBV.layer.cornerRadius = 6;
            [cell addSubview:whiteTwoBV];
                        
            [whiteTwoBV mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerX.mas_equalTo(cell);
                make.width.mas_equalTo(kSCRATIO(340));
                make.height.mas_equalTo(KSCHEIGHT(35));
                make.top.mas_equalTo(whiteOneBV.mas_bottom);
            }];
            //标题imageV
            UIImageView *whiteTwomgV = [[UIImageView alloc] init];
            whiteTwomgV.clipsToBounds = NO;
            whiteTwomgV.userInteractionEnabled = NO;
            whiteTwomgV.image = [UIImage imageNamed:@"cha2"];
            [whiteTwoBV addSubview:whiteTwomgV];
            [whiteTwomgV mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.mas_equalTo(whiteTwoBV);
                make.left.mas_equalTo(kSCRATIO(10));
                make.width.height.mas_equalTo(kSCRATIO(29));
            }];
            //标题label
            UILabel *whiteTwolabel = [[UILabel alloc] init];
            whiteTwolabel.numberOfLines = 0;
            whiteTwolabel.userInteractionEnabled = NO;
            whiteTwolabel.text = @"第二等级任务已解锁";
            whiteTwolabel.textColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
            whiteTwolabel.font = kFONT(KSCHEIGHT(12));
            [whiteTwoBV addSubview:whiteTwolabel];
            [whiteTwolabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.mas_equalTo(whiteTwoBV);
                make.left.mas_equalTo(whiteTwomgV.mas_right).mas_equalTo(kSCRATIO(10));
            }];
            //查看按钮
            UIButton *whiteTwobtn = [[UIButton alloc] init];
            whiteTwobtn.userInteractionEnabled = NO;
            [whiteTwobtn setFont:kFONT(KSCHEIGHT(11))];
            [whiteTwobtn setBackgroundImage:[UIImage imageNamed:@"立即查看"] forState:UIControlStateNormal];
            [whiteTwoBV addSubview:whiteTwobtn];
            [whiteTwobtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.mas_equalTo(whiteTwoBV);
                make.right.mas_equalTo(kSCRATIO(-20));
                            
            }];
                        
            
            //白色背景veiw3
            UIView *whiteThreeBV = [[UIView alloc] init];
            [whiteThreeBV addGestureRecognizer:chaWhitThreeGes];
            whiteThreeBV.frame = CGRectMake(17.5,887,340,105);
            whiteThreeBV.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
            whiteThreeBV.layer.cornerRadius = KSCHEIGHT(8);
            [cell addSubview:whiteThreeBV];
                                    
            [whiteThreeBV mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerX.mas_equalTo(cell);
                make.width.mas_equalTo(kSCRATIO(340));
                make.height.mas_equalTo(KSCHEIGHT(40));
                make.top.mas_equalTo(whiteTwoBV.mas_bottom).mas_equalTo(KSCHEIGHT(-5));
            }];
            //标题imageV
            UIImageView *whiteThreeImgV = [[UIImageView alloc] init];
            whiteThreeImgV.clipsToBounds = NO;
            whiteThreeImgV.userInteractionEnabled = NO;
            whiteThreeImgV.image = [UIImage imageNamed:@"cha3"];
            [whiteThreeBV addSubview:whiteThreeImgV];
            [whiteThreeImgV mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.mas_equalTo(whiteThreeBV);
                make.left.mas_equalTo(kSCRATIO(10));
                make.width.height.mas_equalTo(kSCRATIO(29));
            }];
            //标题label
            UILabel *whiteThreelabel = [[UILabel alloc] init];
            whiteThreelabel.numberOfLines = 0;
            whiteThreelabel.userInteractionEnabled = NO;
            whiteThreelabel.text = @"第三等级任务已解锁";
            whiteThreelabel.textColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
            whiteThreelabel.font = kFONT(KSCHEIGHT(12));
            [whiteThreeBV addSubview:whiteThreelabel];
            [whiteThreelabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.mas_equalTo(whiteThreeBV);
                make.left.mas_equalTo(whiteThreeImgV.mas_right).mas_equalTo(kSCRATIO(10));
            }];
            //查看按钮
            UIButton *whiteThreebtn = [[UIButton alloc] init];
            whiteThreebtn.userInteractionEnabled = NO;
            [whiteThreebtn setFont:kFONT(KSCHEIGHT(11))];
            [whiteThreebtn setBackgroundImage:[UIImage imageNamed:@"立即查看"] forState:UIControlStateNormal];
            [whiteThreeBV addSubview:whiteThreebtn];
            [whiteThreebtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.mas_equalTo(whiteThreeBV);
                make.right.mas_equalTo(kSCRATIO(-20));
            }];
            
            
        }
        
    }else if(indexPath.section == 3){
        [cell removeAllSubviews];
        
        //底横线
        UIView *lineThreeView = [[UIView alloc] init];
        lineThreeView.backgroundColor = [UIColor colorWithRed:229/255.0 green:229/255.0 blue:229/255.0 alpha:1.0];
        [cell addSubview:lineThreeView];
        
        [lineThreeView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(KSCHEIGHT(0));
            make.left.mas_equalTo(kSCRATIO(20));
            make.right.mas_equalTo(kSCRATIO(-20));
            make.height.mas_equalTo(KSCHEIGHT(0.01));
        }];
        if (indexPath.row == 3) {
            lineThreeView.hidden = YES;
        }
        
        tableView.rowHeight = KSCHEIGHT(50);
        
        UIImageView *CimageZ = [[UIImageView alloc] init];
        CimageZ.image = [UIImage imageNamed:self.sectionTImageArr[indexPath.row]];
        [cell addSubview:CimageZ];
        
        UILabel *CZlabel = [[UILabel alloc] init];
        CZlabel.text = self.sectionTZArr[indexPath.row];
        CZlabel.font = kFONT(18);
        [cell addSubview:CZlabel];
        
        UILabel *CFlabel = [[UILabel alloc] init];
        CFlabel.text = self.sectionTFArr[indexPath.row];
        CFlabel.font = kFONT(12);
        CFlabel.textColor = [UIColor lightGrayColor];
        [cell addSubview:CFlabel];
        UIButton *backButton = [[UIButton alloc] init];
        [backButton setImage:[UIImage imageNamed:@"rightButton"] forState:UIControlStateNormal];
        backButton.tag = indexPath.row;
        [backButton addTarget:self action:@selector(Personalnformation:) forControlEvents:UIControlEventTouchUpInside];
        [cell addSubview:backButton];
        
        
        [CimageZ mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(cell);
//            make.top.mas_offset(kSCRATIO(15));
            make.left.mas_equalTo(cell.mas_left).mas_equalTo( kSCRATIO(7));
            make.width.height.mas_equalTo(kSCRATIO(42));
        }];
        [CZlabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(cell);
            make.right.mas_equalTo(CimageZ.mas_right).mas_equalTo(kSCRATIO(80));
            
        }];
        [CFlabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(cell);
            make.left.mas_equalTo(backButton.mas_left).mas_equalTo(kSCRATIO(-80));
            
        }];
        
        [backButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(cell.mas_right).mas_equalTo(kSCRATIO(-25));
            make.centerY.mas_equalTo(cell);
            make.width.mas_offset(kSCRATIO(9));
            make.height.mas_offset(KSCHEIGHT(16));
        }];
        
        
    }
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
}
//查看1点击事件
-(void)touchWhieOneVevent:(UITapGestureRecognizer *)gesture{
    
    NSLog(@"查看11111111");
}
//查看2点击事件
-(void)touchWhieTwoVevent:(UITapGestureRecognizer *)gesture{
    
    NSLog(@"查看222222222");
}
//查看3点击事件
-(void)touchWhieThreeVevent:(UITapGestureRecognizer *)gesture{
    
    NSLog(@"查看33333333");
}

-(void)sectionControlFrame{
    UserModel *user = [UserModel sharedInstance:UserKey0];
    
    _sectionView.backgroundColor = [UIColor colorWithRed:245/255.0 green:246/255.0 blue:251/255.0 alpha:1.0];
            CAGradientLayer *gl = [CAGradientLayer layer];
            gl.startPoint = CGPointMake(0, 0);
            gl.endPoint = CGPointMake(1, 1);
            gl.colors = @[(__bridge id)[UIColor colorWithRed:247/255.0 green:65/255.0 blue:91/255.0 alpha:1.0].CGColor,(__bridge id)[UIColor colorWithRed:251/255.0 green:171/255.0 blue:102/255.0 alpha:1.0].CGColor];
            gl.locations = @[@(0.0),@(1.0)];
            [_sectionView.layer addSublayer:gl];

            
            
            //白view
            _Whiteview = [[UIView alloc] init];
            _Whiteview.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
            _Whiteview.layer.shadowColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:0.04].CGColor;
            _Whiteview.layer.shadowOffset = CGSizeMake(0,2);
            _Whiteview.layer.shadowOpacity = 1;
            _Whiteview.layer.shadowRadius = 2;
            _Whiteview.layer.cornerRadius = 5;
            [_sectionView addSubview:self.Whiteview];
            
            //头像
            TouiamgeBtn = [[UIImageView alloc] init];
            [_sectionView addSubview:TouiamgeBtn];
            
            
            TouiamgeBtn.backgroundColor = [UIColor colorWithRed:248/255.0 green:80/255.0 blue:92/255.0 alpha:1.0];
    //        TouiamgeBtn.image = [UIImage imageNamed:@"customer_service01"];
    //        [TouiamgeBtn addTarget:self action:@selector(headeImgClick:) forControlEvents:UIControlEventTouchUpInside];
            TouiamgeBtn.userInteractionEnabled = YES;
            [TouiamgeBtn addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(headeImgClick:)]];
            
    //        [TouiamgeBtn setBackgroundImage:[UIImage imageNamed:@"customer_service01"] forState:UIControlStateNormal];
            TouiamgeBtn.image = [UIImage imageNamed:@"customer_service01"];
            TouiamgeBtn.layer.shadowColor = [UIColor colorWithRed:173/255.0 green:172/255.0 blue:172/255.0 alpha:0.14].CGColor;
            if ([UtilTools isBlankString:user.portrait]) {
                [TouiamgeBtn sd_setImageWithURL:[NSURL URLWithString:user.portrait] placeholderImage:[UIImage imageNamed:@"customer_service01"]];
            }
            TouiamgeBtn.layer.shadowOffset = CGSizeMake(0,2);
            TouiamgeBtn.layer.shadowOpacity = 1;
            TouiamgeBtn.layer.shadowRadius = 4;
            ViewRadius(TouiamgeBtn, kSCRATIO(36));
            //左侧推广文字
            UIButton *ZtuiBtn = [[UIButton alloc] init];
            NSMutableAttributedString *Ztuititle = [[NSMutableAttributedString alloc] initWithString:@"立即推广"];
            NSRange titleRange = {0,[Ztuititle length]};
            [Ztuititle addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:titleRange];
            
            [ZtuiBtn setAttributedTitle:Ztuititle
                              forState:UIControlStateNormal];
            [ZtuiBtn.titleLabel setFont:kFONT(15)];
            [Ztuititle addAttribute:NSUnderlineStyleAttributeName
                              value:@(NSUnderlineStyleSingle)
                              range:(NSRange){0,[Ztuititle length]}];
            //此时如果设置字体颜色要这样
            [Ztuititle addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:248/255.0 green:80/255.0 blue:92/255.0 alpha:1.0]  range:NSMakeRange(0,[Ztuititle length])];
            
            //设置下划线颜色...
            [Ztuititle addAttribute:NSUnderlineColorAttributeName value:[UIColor colorWithRed:248/255.0 green:80/255.0 blue:92/255.0 alpha:1.0] range:(NSRange){0,[Ztuititle length]}];
            
            //添加点击方法
            [ZtuiBtn addTarget:self action:@selector(ZtuiBClcik:) forControlEvents:UIControlEventTouchUpInside];
            
            [_sectionView addSubview:ZtuiBtn];
            
            //游客button
            Namebtn = [[UIButton alloc] init];
    //        Namebtn.frame = CGRectMake(170.5,130+80,36,16.5);
            [Namebtn addTarget:self action:@selector(NameBClick:) forControlEvents:UIControlEventTouchUpInside];
            
            NSMutableAttributedString *Nametitle = [[NSMutableAttributedString alloc] initWithString:@"未登录"];
            if (![UtilTools isBlankString:user.nickName]) {
                
                Nametitle = [[NSMutableAttributedString alloc] initWithString:user.nickName];;
                
            }
    //        NSRange NameRange = {0,[Nametitle length]};
    //        [Nametitle addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NameRange];
                    
            [Namebtn setAttributedTitle:Nametitle
                                      forState:UIControlStateNormal];
            [Namebtn.titleLabel setFont:kFONT(18)];
    //        [Nametitle addAttribute:NSUnderlineStyleAttributeName
    //                                  value:@(NSUnderlineStyleSingle)
    //                                  range:(NSRange){0,[Nametitle length]}];
            
            //此时如果设置字体颜色要这样
            [Nametitle addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:248/255.0 green:80/255.0 blue:92/255.0 alpha:1.0]  range:NSMakeRange(0,[Nametitle length])];
            [_Whiteview addSubview:Namebtn];
            
            
            //介绍label
            UILabel *JieSlabel = [[UILabel alloc] init];
            JieSlabel.numberOfLines = 0;
            NSMutableAttributedString *JieSString = [[NSMutableAttributedString alloc] initWithString:@"登录可体验更多专享特权哦~" attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Regular" size: 15],NSForegroundColorAttributeName: [UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0]}];

            if (![UtilTools isBlankString:user.personalSignature]) {
                JieSString = [[NSMutableAttributedString alloc] initWithString:user.personalSignature attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Regular" size: 15],NSForegroundColorAttributeName: [UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0]}];
            }
            
            JieSlabel.attributedText = JieSString;
            [_Whiteview addSubview:JieSlabel];
            
            
            //签到button
            UIButton *QDBtn = [[UIButton alloc] init];
            NSMutableAttributedString *QDtitle = [[NSMutableAttributedString alloc] initWithString:@"立即签到"];
            [QDBtn addTarget:self action:@selector(QDbClick:) forControlEvents:UIControlEventTouchUpInside];
            NSRange QDRange = {0,[QDtitle length]};
            [Ztuititle addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:QDRange];
            
            [QDBtn setAttributedTitle:QDtitle
                              forState:UIControlStateNormal];
            [QDBtn.titleLabel setFont:kFONT(15)];
            [QDtitle addAttribute:NSUnderlineStyleAttributeName
                              value:@(NSUnderlineStyleSingle)
                              range:(NSRange){0,[QDtitle length]}];
            //此时如果设置字体颜色要这样
            [QDtitle addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:248/255.0 green:80/255.0 blue:92/255.0 alpha:1.0]  range:NSMakeRange(0,[QDtitle length])];
            
            //设置下划线颜色...
            [QDtitle addAttribute:NSUnderlineColorAttributeName value:[UIColor colorWithRed:248/255.0 green:80/255.0 blue:92/255.0 alpha:1.0] range:(NSRange){0,[QDtitle length]}];
            
            
            [_sectionView addSubview:QDBtn];
            
            //金币button
            UIButton *Goldbtn = [[UIButton alloc] init];
            NSMutableAttributedString *Goldtitle = [[NSMutableAttributedString alloc] initWithString:@"77777"];
            [Goldbtn setAttributedTitle:Goldtitle
                              forState:UIControlStateNormal];
            [Goldbtn.titleLabel setFont:KMEDIUM(26)];
            
            [Goldbtn addTarget:self action:@selector(GoldBclick:) forControlEvents:UIControlEventTouchUpInside];
            
            //此时如果设置字体颜色要这样
            [Goldtitle addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:248/255.0 green:80/255.0 blue:92/255.0 alpha:1.0]  range:NSMakeRange(0,[Goldtitle length])];
            [_sectionView addSubview:Goldbtn];

            
            //当前金币button
            UIButton *AtGoldbtn = [[UIButton alloc] init];
            NSMutableAttributedString *AtGoldtitle = [[NSMutableAttributedString alloc] initWithString:@"当前金币"];
            [AtGoldbtn setAttributedTitle:AtGoldtitle
                              forState:UIControlStateNormal];
            [AtGoldbtn.titleLabel setFont:kFONT(14)];
            [AtGoldbtn addTarget:self action:@selector(AtGoldClick:) forControlEvents:UIControlEventTouchUpInside];
            
            //此时如果设置字体颜色要这样
            [AtGoldtitle addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0]  range:NSMakeRange(0,[AtGoldtitle length])];
            [_sectionView addSubview:AtGoldbtn];
            
            //左箭头button
            UIButton *LeftJObtn = [[UIButton alloc] init];
            [LeftJObtn setBackgroundImage:[UIImage imageNamed:@"leftButton"] forState:UIControlStateNormal];
            [LeftJObtn addTarget:self action:@selector(LeftJObtnClick:) forControlEvents:UIControlEventTouchUpInside];
            [_sectionView addSubview:LeftJObtn];
            
            //灰色竖线
            UIView *LightLine = [[UIView alloc] init];
            LightLine.backgroundColor = [UIColor colorWithRed:191/255.0 green:191/255.0 blue:191/255.0 alpha:1.0];
            [_sectionView addSubview:LightLine];
            
            //余额button
            UIButton *Sumbtn = [[UIButton alloc] init];
            [Sumbtn addTarget:self action:@selector(SumbClick:) forControlEvents:UIControlEventTouchUpInside];
            NSMutableAttributedString *Sumtitle = [[NSMutableAttributedString alloc] initWithString:@"77.77"];
            [Sumbtn setAttributedTitle:Sumtitle
                              forState:UIControlStateNormal];
            [Sumbtn.titleLabel setFont:KMEDIUM(26)];
            
            //此时如果设置字体颜色要这样
            [Sumtitle addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:248/255.0 green:80/255.0 blue:92/255.0 alpha:1.0]  range:NSMakeRange(0,[Sumtitle length])];
            [_sectionView addSubview:Sumbtn];

            
            //当前金币button
            UIButton *AtSumbtn = [[UIButton alloc] init];
            [AtSumbtn addTarget:self action:@selector(AtSumClick:) forControlEvents:UIControlEventTouchUpInside];
            NSMutableAttributedString *AtSumtitle = [[NSMutableAttributedString alloc] initWithString:@"余额(元)"];
            [AtSumbtn setAttributedTitle:AtSumtitle
                              forState:UIControlStateNormal];
            [AtSumbtn.titleLabel setFont:kFONT(14)];
            
            //此时如果设置字体颜色要这样
            [AtSumtitle addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0]  range:NSMakeRange(0,[AtSumtitle length])];
            [_sectionView addSubview:AtSumbtn];
            
            //左箭头button
            UIButton *LeftJTbtn = [[UIButton alloc] init];
            [LeftJTbtn setBackgroundImage:[UIImage imageNamed:@"leftButton"] forState:UIControlStateNormal];
            [LeftJTbtn addTarget:self action:@selector(LeftJTClick:) forControlEvents:UIControlEventTouchUpInside];
            [_sectionView addSubview:LeftJTbtn];
            
            
            //提现button
            UIButton *Txbtn = [[UIButton alloc] init];
            [Txbtn.titleLabel setFont:kFONT(12)];
            [Txbtn setBackgroundImage:[UIImage imageNamed:@"tixian"] forState:UIControlStateNormal];
            [Txbtn addTarget:self action:@selector(TxbtnClick:) forControlEvents:UIControlEventTouchUpInside];
            [_sectionView addSubview:Txbtn];
            
            
            //设置button
            UIButton *Szbtn = [[UIButton alloc] init];
            [Szbtn.titleLabel setFont:kFONT(12)];
            [Szbtn setBackgroundImage:[UIImage imageNamed:@"设置"] forState:UIControlStateNormal];
            [Szbtn addTarget:self action:@selector(SzBtnClick:) forControlEvents:UIControlEventTouchUpInside];
            
            [_sectionView addSubview:Szbtn];
            
            
            //广告栏
    //        [self getSCrlImageArray];
    //        [self setSCrollViewF];
            
            
    //        NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"77777" attributes:@{NSFontAttributeName: [UIFont fontWithName:@"Adobe Heiti Std" size: 24],NSForegroundColorAttributeName: [UIColor colorWithRed:248/255.0 green:80/255.0 blue:92/255.0 alpha:1.0]}];
    //
    //        Gloldlabel.attributedText = string;
            
            
            gl.frame = CGRectMake(0,0,kSCRATIO(375),KSCHEIGHT(183+40));
            
    [_sectionView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(kSCRATIO(0));
        make.top.mas_offset(KSCHEIGHT(0));
        make.right.mas_equalTo(kSCRATIO(0));
        make.bottom.mas_offset(KSCHEIGHT(0));
        
    }];
            [_Whiteview mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(kSCRATIO(10));
                make.top.mas_offset(KSCHEIGHT(83+40));
                make.width.mas_equalTo(kSCRATIO(355));
                make.height.mas_equalTo(KSCHEIGHT(175));
            }];
            [TouiamgeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(kSCRATIO(151));
                make.top.mas_offset(KSCHEIGHT(47+40));
                make.width.height.mas_equalTo(kSCRATIO(73));
                
            }];
            [ZtuiBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(_Whiteview.mas_left).mas_equalTo(kSCRATIO(30));
            make.top.mas_equalTo(_Whiteview.mas_top).mas_equalTo(kSCRATIO(20));

            }];
            [Namebtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerX.mas_equalTo(_Whiteview); make.top.mas_equalTo(TouiamgeBtn.mas_bottom).mas_equalTo(KSCHEIGHT(0));
                make.width.mas_equalTo(kSCRATIO(160));
            }];
            [JieSlabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerX.mas_equalTo(_Whiteview); make.top.mas_equalTo(Namebtn.mas_bottom).mas_equalTo(KSCHEIGHT(0));
                
            }];
            [QDBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(_Whiteview.mas_right).mas_equalTo(kSCRATIO(-30));
            make.top.mas_equalTo(_Whiteview.mas_top).mas_equalTo(kSCRATIO(20));

            }];
            [Goldbtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(_Whiteview.mas_left).mas_equalTo(kSCRATIO(45));
            make.bottom.mas_equalTo(_Whiteview.mas_bottom).mas_equalTo(kSCRATIO(-30));
                

            }];
            [AtGoldbtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerX.mas_equalTo(Goldbtn);
            make.top.mas_equalTo(Goldbtn.mas_top).mas_equalTo(kSCRATIO(35));

            }];
            [LeftJObtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.mas_equalTo(Goldbtn.mas_right).mas_equalTo(kSCRATIO(25));
            make.top.mas_equalTo(Goldbtn.mas_top).mas_equalTo(kSCRATIO(30));
                make.width.mas_equalTo(kSCRATIO(9.5));
                make.height.mas_equalTo(kSCRATIO(17));
                

            }];
            [LightLine mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.mas_equalTo(LeftJObtn.mas_right).mas_equalTo(kSCRATIO(30));
                make.bottom.mas_equalTo(_Whiteview.mas_bottom).mas_equalTo(kSCRATIO(-20));
                make.width.mas_equalTo(kSCRATIO(1));
                make.height.mas_equalTo(kSCRATIO(50));
                

            }];
            [Sumbtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(LightLine.mas_right).mas_equalTo(kSCRATIO(125));
            make.bottom.mas_equalTo(_Whiteview.mas_bottom).mas_equalTo(kSCRATIO(-30));
                

            }];
            [AtSumbtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerX.mas_equalTo(Sumbtn);
            make.top.mas_equalTo(Sumbtn.mas_top).mas_equalTo(kSCRATIO(35));

            }];
            [LeftJTbtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.mas_equalTo(Sumbtn.mas_right).mas_equalTo(kSCRATIO(25));
            make.top.mas_equalTo(Sumbtn.mas_top).mas_equalTo(kSCRATIO(30));
                make.width.mas_equalTo(kSCRATIO(9.5));
                make.height.mas_equalTo(kSCRATIO(17));
                

            }];
            [Txbtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.mas_equalTo(LightLine.mas_right).mas_equalTo(kSCRATIO(60));
            make.top.mas_equalTo(Sumbtn.mas_top).mas_equalTo(kSCRATIO(45));
                make.width.mas_equalTo(kSCRATIO(35));
                make.height.mas_equalTo(kSCRATIO(15));
                

            }];
            [Szbtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.mas_equalTo(_Whiteview.mas_right).mas_equalTo(kSCRATIO(0));
            make.top.mas_equalTo(_Whiteview.mas_top).mas_equalTo(KSCHEIGHT(-55));
                make.width.height.mas_equalTo(kSCRATIO(25));
                


            }];
}
//cell分区0点击事件
-(void)yaoBtnclick:(UIButton *)btn{
    UserModel *user = [UserModel sharedInstance:UserKey0];
    if (btn.tag == 0) {
        if ([UtilTools isBlankString:user.token]) {
                [NotLoginView gotoLoginViewController];
        }else{
        YaoQzViewController *yaoqZQV = [[YaoQzViewController alloc] init];
        [self.navigationController pushViewController:yaoqZQV animated:NO];
        }
    }else if (btn.tag == 1){
        if ([UtilTools isBlankString:user.token]) {
                [NotLoginView gotoLoginViewController];
        }else{
        MeiRQViewController *meirqV = [[MeiRQViewController alloc] init];
        [self.navigationController pushViewController:meirqV animated:NO];
        }
    }else if (btn.tag == 2){
        if ([UtilTools isBlankString:user.token]) {
                [NotLoginView gotoLoginViewController];
        }else{
        KanSpViewController *kansV = [[KanSpViewController alloc] init];
        [self.navigationController pushViewController:kansV animated:NO];
        }
        
    }else if (btn.tag == 3){
        if ([UtilTools isBlankString:user.token]) {
                [NotLoginView gotoLoginViewController];
        }else{
        KanXwViewController *kanXwV = [[KanXwViewController alloc] init];
        [self.navigationController pushViewController:kanXwV animated:NO];
        }
        
    }else if (btn.tag == 4){
        if ([UtilTools isBlankString:user.token]) {
                [NotLoginView gotoLoginViewController];
        }else{
        PaiHBViewController *paihbV = [[PaiHBViewController alloc] init];
        [self.navigationController pushViewController:paihbV animated:NO];
        }
        
    }else if (btn.tag == 5){
        if ([UtilTools isBlankString:user.token]) {
                [NotLoginView gotoLoginViewController];
        }else{
        JieSRwViewController *jsRwV = [[JieSRwViewController alloc] init];
        [self.navigationController pushViewController:jsRwV animated:NO];
        }
        
    }
}
//返回按钮点击事件
-(void)Personalnformation:(UIButton *)btn{
    UserModel *user = [UserModel sharedInstance:UserKey0];
    if (btn.tag == 0) {
        
        if ([UtilTools isBlankString:user.token]) {
            [NotLoginView gotoLoginViewController];
        }else{
            YaoQMViewController *yaoqZV = [[YaoQMViewController alloc] init];
            [self.navigationController pushViewController:yaoqZV animated:NO];
        }
        
    }else if (btn.tag == 1){
            SwViewController *swV = [[SwViewController alloc] init];
            [self.navigationController pushViewController:swV animated:NO];
    }else if (btn.tag == 2){
        GFkfViewController *gfkfV = [[GFkfViewController alloc] init];
        [self.navigationController pushViewController:gfkfV animated:NO];
    }else if (btn.tag == 3){
        
        if ([UtilTools isBlankString:user.token]) {
//            [NotLoginView gotoLoginViewController];
            
        }else{
            BanSViewController *banSV = [[BanSViewController alloc] init];
            [self.navigationController pushViewController:banSV animated:NO];
        }
    }
    
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    UserModel *user = [UserModel sharedInstance:UserKey0];
    if (indexPath.section == 2) {
        if (indexPath.row == 0) {
            if ([UtilTools isBlankString:user.token]) {
                [NotLoginView gotoLoginViewController];
            }else{
                YaoQzViewController *yaoqZQV = [[YaoQzViewController alloc] init];
                [self.navigationController pushViewController:yaoqZQV animated:NO];
            }
        }else if (indexPath.row == 1){
            if ([UtilTools isBlankString:user.token]) {
                [NotLoginView gotoLoginViewController];
            }else{
                MeiRQViewController *meirqV = [[MeiRQViewController alloc] init];
                [self.navigationController pushViewController:meirqV animated:NO];
            }
            
        }else if (indexPath.row == 2){
            if ([UtilTools isBlankString:user.token]) {
                [NotLoginView gotoLoginViewController];
            }else{
                KanSpViewController *kansV = [[KanSpViewController alloc] init];
                [self.navigationController pushViewController:kansV animated:NO];
            }
        }else if (indexPath.row == 3){
            if ([UtilTools isBlankString:user.token]) {
                [NotLoginView gotoLoginViewController];
            }else{
                KanXwViewController *kanXwV = [[KanXwViewController alloc] init];
                [self.navigationController pushViewController:kanXwV animated:NO];
            }
        }else if (indexPath.row == 4){
            if ([UtilTools isBlankString:user.token]) {
                [NotLoginView gotoLoginViewController];
            }else{
            PaiHBViewController *paihbV = [[PaiHBViewController alloc] init];
            [self.navigationController pushViewController:paihbV animated:NO];
            }
        }else if (indexPath.row == 5){
            if ([UtilTools isBlankString:user.token]) {
                [NotLoginView gotoLoginViewController];
            }else{
            JieSRwViewController *jsRwV = [[JieSRwViewController alloc] init];
            [self.navigationController pushViewController:jsRwV animated:NO];
            }
        }
    }else if (indexPath.section == 3){
        if (indexPath.row == 0) {
            if ([UtilTools isBlankString:user.token]) {
                [NotLoginView gotoLoginViewController];
            }else{
            YaoQMViewController *yaoqZV = [[YaoQMViewController alloc] init];
            [self.navigationController pushViewController:yaoqZV animated:NO];
            }
        }else if (indexPath.row == 1){
            SwViewController *swV = [[SwViewController alloc] init];
            [self.navigationController pushViewController:swV animated:NO];
            
        }else if (indexPath.row == 2){
            GFkfViewController *gfkfV = [[GFkfViewController alloc] init];
            [self.navigationController pushViewController:gfkfV animated:NO];
            
        }else if (indexPath.row == 3){
            if ([UtilTools isBlankString:user.token]) {
//                [NotLoginView gotoLoginViewController];
                
            }else{
            BanSViewController *banSV = [[BanSViewController alloc] init];
            [self.navigationController pushViewController:banSV animated:NO];
            }
                
        }
    }
    
    
}

- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index{
    UserModel *user = [UserModel sharedInstance:UserKey0];
    if ([UtilTools isBlankString:user.token]) {
            [NotLoginView gotoLoginViewController];
    }else{
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.urlArray[index]] options:@{} completionHandler:nil];
    }
}
-(void)headeImgClick:(UIButton *)tap{
    UserModel *user = [UserModel sharedInstance:UserKey0];
    if ([UtilTools isBlankString:user.token]) {
//        [[AppDelegate shareAppDelegate] setLoginViewController];
        [NotLoginView gotoLoginViewController];
        return;
    }
    [ZZQAvatarPicker startSelected:^(UIImage * _Nonnull image) {
        if (image) {
//            public static final String bucketName = "kuailejituan";//"hgjt-oss";
//            public static final String objectName = "Image";
            [MessageAlertView showLoading:@""];
            NSData * imageData= UIImageJPEGRepresentation(image, 0.8);
           __block  NSString * fileName = [NSString stringWithFormat:@"%@.%@",[UtilTools getDifferenceUUID],@"jpg"];
            NSString * objectKey = [NSString stringWithFormat:@"Image/%@",fileName];
            
            
            OSSPutObjectRequest * put = [OSSPutObjectRequest new];
            // 必填字段
            put.bucketName = @"kuailejituan";
            put.objectKey = objectKey;
            //    put.uploadingFileURL = [NSURL fileURLWithPath:uploadFilePath];
            put.contentType = [NSString stringWithFormat:@"Image/%@",@"jpg"];
            
            put.uploadingData =imageData; // 直接上传NSData
            // 可选字段，可不设置
            put.uploadProgress = ^(int64_t bytesSent, int64_t totalByteSent, int64_t totalBytesExpectedToSend) {
                // 当前上传段长度、当前已经上传总长度、一共需要上传的总长度
                NSLog(@"%lld, %lld, %lld", bytesSent, totalByteSent, totalBytesExpectedToSend);
            };
            
            //    可以在上传时设置元信息或者其他HTTP头部
            OSSTask * putTask = [[AppDelegate shareAppDelegate].client putObject:put];
            [putTask continueWithBlock:^id(OSSTask *task) {
                
                task = [[AppDelegate shareAppDelegate].client presignPublicURLWithBucketName:@"kuailejituan"
                        
                                                                               withObjectKey:objectKey];
                
                NSLog(@"objectKey: %@", put.objectKey);
                UserModel * user = [UserModel sharedInstance:UserKey0];
                if (!task.error) {
                    fileName = [NSString stringWithFormat:@"https://kuailejituan.oss-cn-hongkong.aliyuncs.com/Image/%@",fileName];
                    NSLog(@"upload object success!");
                    NSDictionary * dic  = [NSDictionary dictionaryWithObjectsAndKeys:
                                           user.token,@"token",
                                           fileName,@"avatar",
                                           nil];
                    @weakify(self);
                    [[NetWorkManager sharedManager] postJSON:@"api/user/updateUser" parameters:dic success:^(NSURLSessionDataTask *task, id responseObject) {
                        dispatch_async(dispatch_get_main_queue(), ^{
                            [MessageAlertView dismissHud];
                            if ([responseObject[@"code"] integerValue]==200) {
                                [TouiamgeBtn sd_setImageWithURL:[NSURL URLWithString:user.portrait] placeholderImage:[UIImage imageNamed:@"customer_service01"]];

                                
                                user.portrait=fileName;
                                
                                [UserModel saveData:UserKey0];
                                dispatch_async(dispatch_get_main_queue(), ^{
                                    [weak_self.table reloadData];
                                });
                            }else
                            {
                                dispatch_async(dispatch_get_main_queue(), ^{
                                    [HWProgressHUD showMessage:responseObject[@"message"]];
                                });
                            }
                        });
                        
                        
                    } failure:^(NSURLSessionDataTask *task, NSError *error) {
                        dispatch_async(dispatch_get_main_queue(), ^{
                            [MessageAlertView dismissHud];
                            
                        });
                    }];
                    
                    
                } else {
                    dispatch_async(dispatch_get_main_queue(), ^{
                        [MessageAlertView dismissHud];
                        
                        [HWProgressHUD showMessage:@"图片上传失败,请重新上传"];
                        
                    });
                    NSLog(@"upload object failed, error: %@" , task.error);
                    
                    
                }
                return nil;
            }];
        }
        
    }];
}





@end
